package cn.tedu.application.controller;

import cn.tedu.application.pojo.dto.ApplicationParam;
import cn.tedu.application.pojo.dto.ApplicationQuery;
import cn.tedu.application.pojo.vo.ApplicationVO;
import cn.tedu.application.service.ApplicationService;
import cn.tedu.base.response.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/application/")
public class ApplicationController {
    @Autowired
    private ApplicationService applicationService;

    @GetMapping("selectInitiate")
    public JsonResult selectInitiate(ApplicationQuery applicationQuery) {
        log.debug("【查询我发起的申请】的请求，参数：{}", applicationQuery);
        List<ApplicationVO> list = applicationService.selectInitiate(applicationQuery);
        return JsonResult.ok(list);
    }

    @GetMapping("selectAudit")
    public JsonResult selectAudit(ApplicationQuery applicationQuery) {
        log.debug("【查询我处理的申请】的请求，参数：{}", applicationQuery);
        List<ApplicationVO> list = applicationService.selectAudit(applicationQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("delete")
    public JsonResult delete(@RequestBody ApplicationParam applicationParam) {
        log.debug("【删除流程】的请求，参数：{}", applicationParam);
        applicationService.delete(applicationParam);
        return JsonResult.ok();
    }
}
